<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <img is="my-img" src="" alt="">

    <script>
        class myIMG extends HTMLImageElement {
            constructor() {
                super()
                console.log("这里是扩展的组件")
                setTimeout(() => {
                    this.src = "https://img0.baidu.com/it/u=3182669744,3015526205&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500"
                }, 1000)
            }
        }

        customElements.define('my-img', myIMG, {
            extends: 'img'
        })

    </script>
</body>

</html>